<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<ui:composition template="/meringerTemplate.xhtml">

		<ui:define name="title">Race Results</ui:define>
		
		<ui:define name="custom">
			<style media="screen" type="text/css">
				.wrapper {
					background-image: url("img/rosneath-circuit.jpg");
				}
				#content {
					background-color: transparent;
					background-image: none;
				}
				
			</style>	
		</ui:define>
		
		<ui:define name="content">
		    
		    <h:panelGroup layout="block" rendered="#{raceBean.previousRaceID == null}">
		    	No race was raced :(
		    </h:panelGroup>
		    
		    <h:panelGroup layout="block" rendered="#{raceBean.previousRaceID != null}">
		    	
		    	<ui:param name="race" value="#{raceResultsBean.findRace(raceBean.previousRaceID)}"/>
		    	
		    	<h2 style="text-align: center;">Race standings for #{raceResultsBean.findRace(raceBean.previousRaceID).road.name},  
		    	    #{race.raceTime}
		    	</h2>
		    	
		    	<img src="#{race.road.imgPath}" style="margin-left: 180px;"/>
		     	
				<p:dataList value="#{raceResultsBean.raceResults(raceBean.previousRaceID)}" 
				            var="res" type="ordered">
	    			#{res.user.username}, #{res.user.mainCar.model.name}, Time: #{raceBean.formattedRaceTime(res.time)}
	    			<ui:param name="award" value="#{race.road.award - 50*(res.position-1)}"/>
	    			<h:panelGroup layout="block" rendered="#{res.user == userBean.currentUser}" 
	    						  style="float: right; font-weight: bold; color: #66FF66; margin-right: 245px;">
	    			    You won #{award >= 0 ? award : 0} money
	    				and 20 Experience!!!
	    			</h:panelGroup>
				</p:dataList>
				
				<br/>
				
				<p:button value="RACE AGAIN" outcome="chooseRace?faces-redirect=true" style="float: right; margin-right: 245px; color: #66FF66;;"/>
			
			</h:panelGroup> 
		</ui:define>
		
	</ui:composition>

</html>
